﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Collections;
using System.IO;
using MySql.Data.MySqlClient;
using System.Data.OleDb;
using tag = functionService.tagWork; 
using H = functionService.shorts;
using da = functionService.DATECOD;
using fr = HK.FiscalRegistrar.FiscalRegistrar;
using vv = functionService.serfun_city7;
using rz = functionService.serfun_city7.rz;
using nameCod = functionService.nameCod;

namespace city7.lists
{
    public partial class FormFilters : Form
    {
        public bool IsOk;
        public ArrayList ar;
        public string valueSelect;
        public string stagArr;
        functionService.prm q;
        string[] aa;

        public FormFilters()
        {
            InitializeComponent(); InitializeComponentMy();
            IsOk = false; stagArr = ""; vv.filter.IsSave = false;
        }
        public FormFilters(int iCod_in_PLP_filter)
        {
            InitializeComponent(); InitializeComponentMy(iCod_in_PLP_filter);
            IsOk = false; stagArr = ""; vv.filter.IsSave = false;
        }
        private void InitializeComponentMy()
        {
            q = new functionService.prm("PLP_filter"); stagArr = q.tk(1); aa = tag.readTAG_ToArray(stagArr);
            ar = new ArrayList();
            for (int j = 0; j < aa.Length; j++)
            {
                ar.Add(aa[j]);
            }
            load();
        }
        private void InitializeComponentMy(int iCod_in_PLP_filter)
        {
            q = new functionService.prm("PLP_filter"); stagArr = q.tk(iCod_in_PLP_filter); aa = tag.readTAG_ToArray(stagArr); textBox1.Visible = false;
            ar = new ArrayList();
            for (int j = 0; j < aa.Length; j++)
            {
                ar.Add(aa[j]);
            }
            load();
        }
        private void load()
        {
            int ic= ar.Count;
            for(int j=0; j<ic;j++)
            {
                listBox1.Items.Add(ar[j].ToString());
            }
             
        }
        private void listBox1_refresh()
        {
 
        }
        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            IsOk = false; this.Close();
        }
        private void saveToTag()
        {
            stagArr = "";
            for (int j = 0; j < ar.Count; j++)
            {
                if (j == 0)
                { stagArr = ar[j].ToString(); }
                else
                {
                    stagArr = string.Concat(stagArr, ";", ar[j].ToString());
                }
            }
           if (stagArr.Length > 0) q.put(1, stagArr);
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            ar.Add(textBox1.Text); valueSelect = textBox1.Text; IsOk = true;
            
            this.Close();
        }

        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                ar.Add(textBox1.Text); valueSelect = textBox1.Text; IsOk = true; saveToTag();
                //load(); 
                
                //saveToTag();
                this.Close();
            }
        }

        private void listBox1_Click(object sender, EventArgs e)
        {
            valueSelect = listBox1.SelectedItems[0].ToString();  IsOk = true; this.Close();
          // H.m( listBox1.SelectedItems[0].ToString());
        }
    }
}
